package com.zhentao.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhentao.pojo.TbPackage;
import com.zhentao.service.TbPackageService;
import com.zhentao.vo.Query;
import com.zhentao.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/package")
public class TiyanController {
    @Autowired
    private TbPackageService tbPackageService;
    //多条件查询，模糊查询
    @RequestMapping("/findPage")
    public Result findPage(@RequestBody Query query){
        Page<TbPackage> page = tbPackageService.findPage(query);
        return Result.OK(page);
    }

    @RequestMapping("/add")
    public String add(@RequestBody TbPackage tbPackage){
        boolean save = tbPackageService.save(tbPackage);
        return save?"添加成功":"添加失败";
    }
    @RequestMapping("/update")
    public String update(@RequestBody TbPackage tbPackage){
        boolean update = tbPackageService.updateById(tbPackage);
        return update?"修改成功":"修改失败";
    }
    @RequestMapping("/delete")
    public String delete(String packageId){
        boolean delete = tbPackageService.removeById(packageId);
        return delete?"删除成功":"删除失败";
    }


}
